<?php $path = Yii::app()->theme->baseUrl;?>
<div id="menu" class="hidden-print">
	<!-- Brand -->
	<a href="index.html?lang=en&amp;layout_type=fluid&amp;menu_position=menu-left&amp;style=style-default-menus-dark&amp;sidebar_type=collapsible" class="appbrand"><span class="text-primary">FLAT</span> <span>KIT</span></a>

	<!-- Scrollable menu wrapper with Maximum height -->
	<div class="slim-scroll" data-scroll-height="800px">
		<!-- Menu Toggle Button -->
		<button type="button" class="btn btn-navbar">
			<span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
		</button>
		<!-- // Menu Toggle Button END -->

		<!-- Sidebar Profile -->
		<span class="profile center">
			<a href="my_account_advanced.html?lang=en&amp;layout_type=fluid&amp;menu_position=menu-left&amp;style=style-default-menus-dark&amp;sidebar_type=collapsible"><img src="<?php print $path;?>/common/theme/images/profile.jpg" alt="Avatar" /></a>
		</span>
		<!-- // Sidebar Profile END -->

		<!-- Menu -->
		<?php getMenu($this->leftmenu); ?>
		<div class="clearfix"></div>
		<!-- // Menu END -->

	</div>
	<!-- // Scrollable Menu wrapper with Maximum Height END -->

</div>


<?php 
function getMenu( $menus , $sub = false, $url = 'admin')
{
	if (empty($menus))
		return;
	if ($sub)
	{
		echo '<ul class="collapse" id ="'.$sub.'">';
	} else
	{
		echo "<ul>";
	}
	foreach($menus as $key=>$menu)
	{
		if (empty($menu['sub']))
		{
			if (stripos($menu['url'], 'full:'))
			{
				$href = $menu['url'];
			} else {
				$href = $url . '/' . $menu['url'];
			}
			echo '<li><a href="'.$href.'" class="glyphicons '.(empty($menu['icon'])?'':$menu['icon'] ).'"><i></i><span>'.$menu['title'].'</span></a></li>';
		}
		else
		{
			$id = 'adm-lm__'.$key.'-'.getUrl::cleanString( $menu['title'] );
			echo '<li class="hasSubmenu">';
			if ($sub)
			{
				$span = '<span class="badge badge-primary fix">'.sizeof($menu['sub']).'</span>';
			}
			else
			{
				$span = '<span class="icon-chevron-down"></span>';
			}
			echo '<a href="#'.$id.'" data-toggle="collapse" class="glyphicons '.(empty($menu['icon'])?'':$menu['icon']).'"><i></i>'.$menu['title'].$span.'</a>';
			getMenu( $menu['sub'], $id, $url.'/'.$menu['url'] );
			echo '</li>';
		}
	}
	echo "</ul>";
}
?>
